package main.od;

import java.util.*;

public class RegisterRecordTest {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = Integer.parseInt(scanner.nextLine());
        Set<String> errorList = new LinkedHashSet<>();
        Map<Integer,List<String>> map = new HashMap<>();
        for (int i = 0;i < num;i++){
            String line = scanner.nextLine();
            String[] arr = line.split(",");
            int id = Integer.parseInt(arr[0]);
            int clockTime = Integer.parseInt(arr[1]);
            int clockDistance = Integer.parseInt(arr[2]);
            if (!arr[3].equals(arr[4])){
                errorList.add(line);
            }
            List<String> preList = map.get(id);
            if (null != preList){
                for (String preLine : preList){
                    String[] split = preLine.split(",");
                    int time = Math.abs(Integer.parseInt(split[1]) - clockTime);
                    int distance = Math.abs(Integer.parseInt(split[2]) - clockDistance);
                    if (time < 60 && distance > 5){
                        errorList.add(preLine);
                        errorList.add(line);
                    }
                }
            }
            List<String> currentList = new ArrayList<>();
            if (map.containsKey(id)){
                currentList = map.get(id);
            }
            currentList.add(line);
            map.put(id,currentList);
        }
        if (errorList.size() == 0){
            System.out.println("null");
            return;
        }
        StringBuilder builder = new StringBuilder();
        for (String error : errorList){
            builder.append(error).append(";");
        }
        builder.deleteCharAt(builder.length() - 1);
        System.out.println(builder);
    }
}
